

let adminDao =require('../model/backend/admin');
//短信验证函数
exports.validateCode  =async function (phone,code) {
    let msg='';
    let validate = await  adminDao.validateCode(phone,code);
    if(!validate){
        msg='验证码错误';
        return 	msg;
      }   
    //判断验证码是否过期
   let nowDate=new Date();
   let createdDate=validate.createdAt;
   let differenceTime=nowDate.getTime() - createdDate.getTime();
   let minutes=Math.floor(differenceTime/(60*1000))
   if(minutes>5){
    msg='验证码已过期，请重新获取';
        return 	msg;
   }  
   msg=true;
   return msg;  
}